﻿using MySql.Data.MySqlClient;
using System;

class Program
{
    static void Main()
    {
        DisplaySampleData();
        Console.ReadLine(); // 保持控制台窗口打开
    }

    static void DisplaySampleData()
    {
        string connectionString = "Server=localhost;Database=LibraryManagementSystem;Uid=root;Pwd=q12346789;";

        using (var connection = new MySqlConnection(connectionString))
        {
            connection.Open();

            // 显示用户数据
            Console.WriteLine("=== 用户数据 ===");
            using (var cmd = new MySqlCommand("SELECT Username, RealName, UserType FROM Users", connection))
            using (var reader = cmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    Console.WriteLine($"用户名: {reader["Username"]}, 姓名: {reader["RealName"]}, 类型: {reader["UserType"]}");
                }
            }

            // 显示图书数据
            Console.WriteLine("\n=== 图书数据 ===");
            using (var cmd = new MySqlCommand("SELECT ISBN, Title, Author, AvailableCopies FROM Books", connection))
            using (var reader = cmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    Console.WriteLine($"ISBN: {reader["ISBN"]}, 书名: {reader["Title"]}, 作者: {reader["Author"]}, 可借数量: {reader["AvailableCopies"]}");
                }
            }
        }
    }
}